package com.yunkeji.common.enums.app;

import com.yunkeji.common.exception.AppServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/** 0=等待审核 1=等待到账 2=已经到账 3=到账异常 */
@Getter
@AllArgsConstructor
public enum WithdrawPayStatus {
    等待审核(0),
    等待到账(1),
    已经到账(2),
    到账异常(3);
    private Integer code;

    public static WithdrawPayStatus getByCode(Integer code) {
        WithdrawPayStatus[] values = WithdrawPayStatus.values();
        Optional<WithdrawPayStatus> first =
                Arrays.stream(values).filter(item -> item.getCode().equals(code)).findFirst();
        if (first.isPresent()) {
            return first.get();
        } else {
            throw AppServiceException.paramException("付款状态参数异常");
        }
    }
}
